package com.gaoch.simweather.logic.network

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object  ServiceCreator {
    private const val BASE_URL_PLACE="https://geoapi.heweather.net/"
    private val retrofitPlace=Retrofit.Builder()
        .baseUrl(BASE_URL_PLACE)
        .addConverterFactory(GsonConverterFactory.create())
        .build()
    fun <T> createPlace(serviceClass: Class<T>):T= retrofitPlace.create(serviceClass)
    inline fun <reified T> createPlace():T= createPlace(T::class.java)

    private const val BASE_URL_WEATHER="https://devapi.heweather.net/"
    private val retrofitWeather=Retrofit.Builder()
        .baseUrl(BASE_URL_WEATHER)
        .addConverterFactory(GsonConverterFactory.create())
        .build()
    fun <T> createWeather(serviceClass: Class<T>):T= retrofitWeather.create(serviceClass)
    inline fun <reified T> createWeather():T= createWeather(T::class.java)
}